home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
pctj0787.arc
/
MEMCHK.C
< prev
next >
Wrap
C/C++ Source or Header
|
1987-05-27
|
846b
|
36 lines
/*
* memchk -- look for random-access memory at
* a specified location; return non-zero if found
*/
#include <dos.h>
#include <memory.h>
int
memchk(seg, os)
unsigned int seg;
unsigned int os;
{
unsigned char tstval, oldval, newval;
unsigned int ds;
struct SREGS segregs;
/* get value of current data segment */
segread(&segregs);
ds = segregs.ds;
/* save current contents of test location */
movedata(seg, os, ds, (unsigned)&oldval, 1);
/* copy a known value into test location */
tstval = 0xFC;
movedata(ds, (unsigned)&tstval, seg, os, 1);
/* read test value back and comapre to value written */
movedata(seg, os, ds, (unsigned)&newval, 1);
if (newval != tstval)
return (0);
/* restore original contents of test location */
movedata(ds, (unsigned)&oldval, seg, os, 1);
return (1);
}